package id

import (
	"core/config"
	"time"
)

var (
	Idutil *Worker
	Config = &IdConfig{}
)

func NewId() int64 {
	return Idutil.GetId()
}

func GetTimestampById(id int64) int64 {
	return Idutil.getTimestampById(id)
}

func GetIdByDate(t time.Time) int64 {
	return Idutil.GetIdByDate(t)
}
func GetDateById(id int64) time.Time {
	return Idutil.GetDateById(id)
}

func UuidStr() string {
	return Idutil.UuidStr()
}
func init() {
	config.ConfigViper.UnmarshalKey("id", Config)
	Idutil = newWorker(Config.MachineID, Config.ServiceID)

}
